package com.senlingspace.web.controller.headquarters;

import com.github.pagehelper.PageInfo;
import com.senlingspace.common.annotation.Log;
import com.senlingspace.common.core.page.TableDataInfo;
import com.senlingspace.common.enums.BusinessType;
import com.senlingspace.common.utils.poi.ExcelUtil;
import com.senlingspace.system.domain.SlkjInvestor;
import com.senlingspace.system.domain.vo.GoodsIncomeVo;
import com.senlingspace.system.service.SlkjGoodsIncomeService;
import com.senlingspace.common.core.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.List;

/**
 *
 *
 * @author Administrator
 */
@RestController
@RequestMapping("/system/goodsIncome")
public class SlkjGoodsIncomeController extends BaseController{

    @Autowired
    private SlkjGoodsIncomeService slkjGoodsIncomeService;
    @PreAuthorize("@ss.hasPermi('system:goodsIncome:list')")
    @GetMapping("/list")
    public TableDataInfo list( Date startTime,Date endTime,Long shopId,Long productTpyeId) {
        PageInfo<GoodsIncomeVo> list = slkjGoodsIncomeService.selectGoodsIncomeList(startTime,endTime,shopId,productTpyeId);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('system:goodsIncome:export')")
    @Log(title = "商品结算汇总表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Date startTime,Date endTime,Long shopId,Long productTpyeId)
    {
        // PageInfo<GoodsIncomeVo> list = slkjGoodsIncomeService.selectGoodsIncomeList(startTime,endTime,shopId,productTpyeId);
        List<GoodsIncomeVo> list = slkjGoodsIncomeService.exportGoodsIncomeList(startTime, endTime, shopId, productTpyeId);
        ExcelUtil<GoodsIncomeVo> util = new ExcelUtil<>(GoodsIncomeVo.class);
        util.exportExcel(response, list, "商品结算汇总数据");
    }
}
